﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;


namespace MvcApplication1.Models
{
    public class Home
    {
        DataClassesDicDataContext context = new DataClassesDicDataContext();

        public object getData()
        {
            var dic = from fc in context.jishous
                      select new
                      {
                          fc.key,
                          fc.value,
                      };

            return dic;
        }

        public object getData(string keyword)
        {
            
            var dic = from fc in context.jishous
                      where fc.key.Contains(keyword) || fc.value.Contains(keyword)
                      select new
                      {
                          fc.key,
                          fc.value,
                      };

            return dic;
        }

        public bool insert(string key, string value) {

            var pro = new jishou
            {
                key = key,
                value = value
            };
            context.jishous.InsertOnSubmit(pro);
            context.SubmitChanges();
            return true;
        }
    }
}